<?php
/*
$JA#COPYRIGHT$
*/

// no direct access
defined( '_JEXEC' ) or die( 'Restricted access' );

require_once( dirname(__FILE__).DS.'helper.php' );
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jaconstants.php';
require_once JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'japermissions.php';
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jafunctions.class.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'models'.DS.'japrofiles.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'models'.DS.'jajobs.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'helper'.DS.'jahelper.php');
global $mainframe,$jbconfig;
JHTML::_('behavior.tooltip');
component_configs();
//checkPermission('view_list_profiles');

$modStyle = $params->get( 'style', 'default' );

if( 1 ){
    global $mainframe;
            
    if(file_exists(JPATH_BASE.DS.'templates/'.$mainframe->getTemplate().'/css/ja.jobboard.css')){
    	JHTML::stylesheet('ja.jobboard.css', 'templates/'.$mainframe->getTemplate().'/css/');
    }
    else{
    	JHTML::stylesheet('ja.jobboard.css', 'components/'. 'com_jajobboard' .'/css/');
    }    	 	 	 
    JHTML::script('ja.jobboard.js', 'components/com_jajobboard/js/');
    JHTML::script('joomla.javascript.js', 'includes/js/');
    
    // define('JAJOBBOARD_GLOBAL_CSS', 1);
    
    if( $modStyle == 'scroll' ){
        $document = JFactory::getDocument();
        $document->addStyleSheet("modules/mod_jafeatured_employer/assets/css/jquery.css");
        $document->addStyleSheet("modules/mod_jafeatured_employer/assets/css/default.css");
		$document->addScript ('modules/mod_jafeatured_employer/assets/js/jquery.tools.min.js');
        $document->addScript("modules/mod_jafeatured_employer/assets/js/jquery.js");        
		$document->addScript("modules/mod_jafeatured_employer/assets/js/carousel.js");        
    }
}    

/* Requirement Cache*/
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jacache'.DS.'jacache.php');
require_once(JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'asset'.DS.'jacache'.DS.'jajob.inc.php');
global $jbconfig;
$cache = new JA_Cache($jbconfig['cache']->get('cache_base', JPATH_SITE.DS.'components'.DS.'com_jajobboard'.DS.'cache'), $jbconfig['cache']->get('cache_time', 5), $jbconfig['cache']->get('caching', true));
$cache_id = md5('mod_jafeatured_employer');
$cache_group = 'jaemployers';
if($cache->check_cache($cache_id, $cache_group)) return ;
else $oldlen = strlen(ob_get_contents());
/* End cache */


$baseurl = JURI::base();
$tags 			= addslashes(str_replace("\n","", $mainframe->getCfg( 'MetaKeys' )));
$tags 			= trim($tags);
$tags_space		= str_replace(',', ' ', $tags);
$tags_semi 		= str_replace(',', ';', $tags);
$tags_space     = str_replace('  ', ' ', $tags_space);
$description    = addslashes($mainframe->getCfg( 'MetaDesc' ));
$style 			= $params->get('style', "1");
$arr_employer 	= $params->get('employer_list');
$number_employer = $params->get('maximum_display');
$is_hiring		= 	$params->get( 'is_hiring', 1 );

//prepare data
$model = new JobBoardModelJAprofiles();
if (is_array($arr_employer))
{
	$str_employer = implode(',',$arr_employer);
	$max_employer = count($arr_employer);
}
else 	
{
	$str_employer = $arr_employer;
	$max_employer = 1;
}

$items = mod_jafeatured_employerHelper::get_list_profiles( $model, $str_employer, $number_employer,$is_hiring, $max_employer);
$number_employer = count($items);


///////////////////////////////////////////

$sb 		    = $params->get('sb', '');
$file 		    = $params->get('file1', '');
$url 		    = $params->get('url1', '');
$frontxt 		    = $params->get('frontxt1', '');
$follow 		    = $params->get('follow1', '');

$number_column 	= $params->get('number_column');
$width_mod 		= $params->get('width_mod');
$item_width 	= $params->get('item_width');
$item_height	= $params->get('item_height');
$thumnail_width = $params->get('thumnail_width');
$thumnail_height = $params->get('thumnail_height');

$align          = $params->get('align', '');
$padd           = intval($params->get('padd', '1'))*5;
$frontxt        = $params->get('frontxt', '');
$follow 		= $params->get('follow', '');

//////////////////////////////////////

require( JModuleHelper::getLayoutPath( 'mod_jafeatured_employer', $modStyle ) );

/* Set cache */
$maincontent = substr(ob_get_contents(), $oldlen);
if($maincontent){
	$cache->_cache->store($maincontent, $cache_id, $cache_group);		
}

?>